﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SqlServerDataTableToExcel.views
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct MARGINS
        {
            public int Left;
            public int Right;
            public int Top;
            public int Bottom;
        }

    
     




        private void btnAdd_Click(object sender, EventArgs e)
        {

            frmFileEdit frm = new frmFileEdit(null);
            if (frm.ShowDialog() == DialogResult.OK)
            {
                Model.Item_Model msg = frm.objItem;
                DataItem obj = new DataItem(msg);
                obj.delEvent += RemoveDataItem;
                flyMain.Controls.Add(obj);
            }
        }


        private void RemoveDataItem(DataItem obj)
        {
            flyMain.Controls.Remove(obj);
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            ///初始化设置文件
            BLL.LocalDs.Init();

            List<Model.Item_Model> RtnList = BLL.LocalDs.Search();
            foreach (var item in RtnList)
            {
                DataItem obj = new DataItem(item);
                obj.delEvent += RemoveDataItem;
                flyMain.Controls.Add(obj);
            }
        }
    }
}
